package cn.tedu.staff_user.management.dao.persist.repository.impl;

import cn.tedu.common.pojo.po.StaffSearchPO;
import cn.tedu.staff_user.management.dao.persist.mapper.StaffMapper;
import cn.tedu.staff_user.management.dao.persist.repository.IStaffRepository;
import cn.tedu.staff_user.management.pojo.entity.Staff;
import cn.tedu.staff_user.management.pojo.vo.StaffListItemVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class StaffRepositoryImpl implements IStaffRepository {

    @Autowired
    private StaffMapper staffMapper;

    @Override
    public List<StaffListItemVO> list() {
        return staffMapper.list();
    }

    @Override
    public int addNew(Staff staff) {
        return staffMapper.insert(staff);
    }

    @Override
    public int countName(String username) {
        QueryWrapper<Staff> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return staffMapper.selectCount(queryWrapper);
    }

    @Override
    public int deleteById(Long id) {
        return staffMapper.deleteById(id);
    }

    @Override
    public int update(Staff staff) {
        return staffMapper.update(staff);
    }

    @Override
    public int updateById(Staff staff) {
        log.debug("开始执行的数据访问，参数：{}", staff);
        return staffMapper.updateById(staff);
    }
    /**
     * 根据查看优秀员工接口
     */
    @Override
    public List<StaffListItemVO> selectList() {
        log.debug("开始执行【根据I优秀员工数据详情】的数据访问，参数：{}");
        return     staffMapper.selectList();
    }

    @Override
    public List<StaffSearchPO> listSearch() {
        return staffMapper.listSearch();
    }
}
